<!DOCTYPE html>
<html>
<!-- Created by GNU Texinfo 7.1.1, https://www.gnu.org/software/texinfo/ -->
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<!-- Copyright © 1988-2023 Free Software Foundation, Inc.

Permission is granted to copy, distribute and/or modify this document
under the terms of the GNU Free Documentation License, Version 1.3 or
any later version published by the Free Software Foundation; with the
Invariant Sections being "Funding Free Software", the Front-Cover
Texts being (a) (see below), and with the Back-Cover Texts being (b)
(see below).  A copy of the license is included in the section entitled
"GNU Free Documentation License".

(a) The FSF's Front-Cover Text is:

A GNU Manual

(b) The FSF's Back-Cover Text is:

You have freedom to copy and modify this GNU Manual, like GNU
     software.  Copies published by the Free Software Foundation raise
     funds for GNU development. -->
<title>Files (GNU Compiler Collection (GCC) Internals)</title>

<meta name="description" content="Files (GNU Compiler Collection (GCC) Internals)">
<meta name="keywords" content="Files (GNU Compiler Collection (GCC) Internals)">
<meta name="resource-type" content="document">
<meta name="distribution" content="global">
<meta name="Generator" content="makeinfo">
<meta name="viewport" content="width=device-width,initial-scale=1">

<link href="index.html" rel="start" title="Top">
<link href="Option-Index.html" rel="index" title="Option Index">
<link href="index.html#SEC_Contents" rel="contents" title="Table of Contents">
<link href="Type-Information.html" rel="up" title="Type Information">
<link href="Invoking-the-garbage-collector.html" rel="next" title="Invoking the garbage collector">
<link href="GGC-Roots.html" rel="prev" title="GGC Roots">
<style type="text/css">
<!--
a.copiable-link {visibility: hidden; text-decoration: none; line-height: 0em}
span:hover a.copiable-link {visibility: visible}
-->
</style>


</head>

<body lang="en">
<div class="section-level-extent" id="Files">
<div class="nav-panel">
<p>
Next: <a href="Invoking-the-garbage-collector.html" accesskey="n" rel="next">How to invoke the garbage collector</a>, Previous: <a href="GGC-Roots.html" accesskey="p" rel="prev">Marking Roots for the Garbage Collector</a>, Up: <a href="Type-Information.html" accesskey="u" rel="up">Memory Management and Type Information</a> &nbsp; [<a href="index.html#SEC_Contents" title="Table of contents" rel="contents">Contents</a>][<a href="Option-Index.html" title="Index" rel="index">Index</a>]</p>
</div>
<hr>
<h3 class="section" id="Source-Files-Containing-Type-Information"><span>23.5 Source Files Containing Type Information<a class="copiable-link" href="#Source-Files-Containing-Type-Information"> &para;</a></span></h3>
<a class="index-entry-id" id="index-generated-files"></a>
<a class="index-entry-id" id="index-files_002c-generated"></a>

<p>Whenever you add <code class="code">GTY</code> markers to a source file that previously
had none, or create a new source file containing <code class="code">GTY</code> markers,
there are three things you need to do:
</p>
<ol class="enumerate">
<li> You need to add the file to the list of source files the type
machinery scans.  There are four cases:

<ol class="enumerate" type="a" start="1">
<li> For a back-end file, this is usually done
automatically; if not, you should add it to <code class="code">target_gtfiles</code> in
the appropriate port&rsquo;s entries in <samp class="file">config.gcc</samp>.

</li><li> For files shared by all front ends, add the filename to the
<code class="code">GTFILES</code> variable in <samp class="file">Makefile.in</samp>.

</li><li> For files that are part of one front end, add the filename to the
<code class="code">gtfiles</code> variable defined in the appropriate
<samp class="file">config-lang.in</samp>.
Headers should appear before non-headers in this list.

</li><li> For files that are part of some but not all front ends, add the
filename to the <code class="code">gtfiles</code> variable of <em class="emph">all</em> the front ends
that use it.
</li></ol>

</li><li> If the file was a header file, you&rsquo;ll need to check that it&rsquo;s included
in the right place to be visible to the generated files.  For a back-end
header file, this should be done automatically.  For a front-end header
file, it needs to be included by the same file that includes
<samp class="file">gtype-<var class="var">lang</var>.h</samp>.  For other header files, it needs to be
included in <samp class="file">gtype-desc.cc</samp>, which is a generated file, so add it to
<code class="code">ifiles</code> in <code class="code">open_base_file</code> in <samp class="file">gengtype.cc</samp>.

<p>For source files that aren&rsquo;t header files, the machinery will generate a
header file that should be included in the source file you just changed.
The file will be called <samp class="file">gt-<var class="var">path</var>.h</samp> where <var class="var">path</var> is the
pathname relative to the <samp class="file">gcc</samp> directory with slashes replaced by
<code class="verb">-</code>, so for example the header file to be included in
<samp class="file">cp/parser.cc</samp> is called <samp class="file">gt-cp-parser.h</samp>.  The
generated header file should be included after everything else in the
source file.
</p>
</li></ol>

<p>For language frontends, there is another file that needs to be included
somewhere.  It will be called <samp class="file">gtype-<var class="var">lang</var>.h</samp>, where
<var class="var">lang</var> is the name of the subdirectory the language is contained in.
</p>
<p>Plugins can add additional root tables.  Run the <code class="code">gengtype</code>
utility in plugin mode as <code class="code">gengtype -P pluginout.h <var class="var">source-dir</var>
<var class="var">file-list</var> <var class="var">plugin*.c</var></code> with your plugin files
<var class="var">plugin*.c</var> using <code class="code">GTY</code> to generate the <var class="var">pluginout.h</var> file.
The GCC build tree is needed to be present in that mode.
</p>

</div>
<hr>
<div class="nav-panel">
<p>
Next: <a href="Invoking-the-garbage-collector.html">How to invoke the garbage collector</a>, Previous: <a href="GGC-Roots.html">Marking Roots for the Garbage Collector</a>, Up: <a href="Type-Information.html">Memory Management and Type Information</a> &nbsp; [<a href="index.html#SEC_Contents" title="Table of contents" rel="contents">Contents</a>][<a href="Option-Index.html" title="Index" rel="index">Index</a>]</p>
</div>



</body>
</html>
